package com.fpt.edu.jornee.host;

import java.util.ArrayList;
import java.util.HashMap;

import com.fpt.edu.jornee.R;
import com.fpt.edu.jornee.R.id;
import com.fpt.edu.jornee.R.layout;
import com.fpt.edu.jornee.utils.MenuNavigationListAdapter;
import com.viewpagerindicator.IconPagerAdapter;
import com.viewpagerindicator.TabPageIndicator;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTabHost;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.Toast;

public class HostFragment extends Fragment {
	private FragmentTabHost mTabHost;
	private static final String[] CONTENT = new String[] { "Introduce", "Tips",
			"Feedback" };
	private static final int[] ICONS = new int[] {
			R.drawable.perm_group_calendar, R.drawable.perm_group_camera,
			R.drawable.perm_group_device_alarms, };
	Context context;

	public HostFragment() {
		// Empty constructor required for fragment subclasses
	}

	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_host_profile_layout,
				container, false);

		setHasOptionsMenu(true);

		context = rootView.getContext();
		FragmentPagerAdapter adapter = new TapPageAdapter(getFragmentManager());

		ViewPager pager = (ViewPager) rootView.findViewById(R.id.pager);
		pager.setAdapter(adapter);

		TabPageIndicator indicator = (TabPageIndicator) rootView
				.findViewById(R.id.indicator);
		indicator.setViewPager(pager);

		return rootView;

	}

	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);

	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		return super.onOptionsItemSelected(item);
	}

	class TapPageAdapter extends FragmentPagerAdapter implements IconPagerAdapter{

		public TapPageAdapter(FragmentManager fragmentManager) {
			super(fragmentManager);
		}

		@Override
		public CharSequence getPageTitle(int position) {
			return CONTENT[position % CONTENT.length].toUpperCase();
		}

		
		@Override
		public int getCount() {
			return CONTENT.length;
		}

		@Override
		public android.support.v4.app.Fragment getItem(int position) {

			switch (position) {
			case 0:
				return HostIntroduceFragment.newInstance();
			case 1:
				return HostTipsFragment.newInstance();
			case 2:
				return HostFeedbackFragment.newInstance();
			}
			return null;

		}

		@Override
		public int getIconResId(int index) {
			          return ICONS[index];
			        
		}
	}
}
